﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace deWinForms
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Microsoft.TeamFoundation.Client.TfsTeamProjectCollection tfsCollection =
                Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
                new System.Uri(this.textBoxTeamProjectCollection.Text));
            Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore storeWorkItems =
            (Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore)tfsCollection.GetService(typeof(
                Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore));

            int idWorkItem = Convert.ToInt32(this.textBoxWorkItemID.Text);

            Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem objWorkItem = 
                storeWorkItems.GetWorkItem(idWorkItem);
            objWorkItem[this.textBoxRefName.Text] = this.textBoxFieldValue.Text;
            objWorkItem.Save();
            tfsCollection.Dispose();


            }
    }
}


//Microsoft.TeamFoundation.Client.TfsTeamProjectCollection
//Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemType WIT =
//storeWorkItems.Projects[this.textBox2.Text].WorkItemTypes[this.textBox5.Text];
//Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem newWI = WIT.NewWorkItem();
//newWI.Title = this.textBox4.Text;
//newWI.Save(); this.textBox3.Text = "Saved WI #" + newWI.Id.ToString(); 
        
